let container = document.getElementById("container");
let form = document.getElementById("form");
let success = document.getElementById("success");
// 检测dom元素是否包含类名
function containerClass(dom, nclass) {
  let classAtr = dom.getAttribute("class");
  if (classAtr.indexOf(nclass) != -1) return true
  return false;
}
function switchClass(dom, oldClassName, newClassName) {
  let classAtr = dom.getAttribute("class");
  let newClass = classAtr.replace(oldClassName, newClassName);
  dom.setAttribute("class", newClass);
}
// 左滑展示第二页
function leftTwoPart() {
  if (containerClass(container, "fadeInUp")) {
    // 将第一页隐藏
    switchClass(container, "fadeInUp", "fadeOutLeft");
  } else {
    // 将第一页隐藏
    switchClass(container, "fadeInLeft", "fadeOutLeft");
  }
  setTimeout(function () {
    switchClass(container, "fadeOutLeft", "hidden");
  }, 400);
  // 展示第二页
  switchClass(form, "hidden", "fadeInRight");
}
// 右滑回到第一页
function rightOnePart() {
  // 将第二页隐藏
  switchClass(form, "fadeInRight", "fadeOutRight");
  setTimeout(function () {
    switchClass(form, "fadeOutRight", "hidden");
  }, 400);
  // 展示第一页
  switchClass(container, "hidden", "fadeInLeft");
}
// 报备成功后，跳转第三页
function reportSuccess() {
  // 将第二页隐藏
  switchClass(form, "fadeInRight", "fadeOutLeft");
  setTimeout(function () {
    switchClass(form, "fadeOutLeft", "hidden");
  }, 400);
  // 展示最后一页
  switchClass(success, "hidden", "fadeInRight");
}
// 绑定左滑事件
EventUtil.bindEvent(container, 'swipeleft', leftTwoPart);
EventUtil.bindEvent(form, 'swiperight', rightOnePart);